<!-- navbar header -->
<div class="navbar-header {{app.settings.navbarHeaderColor}}">
    <button class="pull-right visible-xs dk" ui-toggle-class="show" data-target=".navbar-collapse">
        <i class="glyphicon glyphicon-cog"></i>
    </button>
    <button class="pull-right visible-xs" ui-toggle-class="off-screen" data-target=".app-aside" ui-scroll="app">
        <i class="glyphicon glyphicon-align-justify"></i>
    </button>
    <!-- brand -->
    <a href="#/" class="navbar-brand text-lt" style="font-size: 13px;">
        <i class="fa fa-btc"></i>
        <img src="img/logo.png" alt="." class="hide">
        <span class="hidden-folded m-l-xs">盈家公寓管理系统</span>
    </a>
    <!-- / brand -->
</div>
<!-- / navbar header -->
<!-- navbar collapse -->
<div class="collapse pos-rlt navbar-collapse box-shadow {{app.settings.navbarCollapseColor}}">
    <!-- buttons -->
    <div class="nav navbar-nav hidden-xs" >
        <a href class="btn no-shadow navbar-btn" ng-click="app.settings.asideFolded = !app.settings.asideFolded" id="screenChanged">
            <i class="fa {{app.settings.asideFolded ? 'fa-indent' : 'fa-dedent'}} fa-fw"></i>
        </a>
        <a href class="btn no-shadow navbar-btn" ui-toggle-class="show" target="#aside-user">
            <i class="icon-user fa-fw"></i>
        </a>
    </div>
    <!-- / buttons -->
    <!-- nabar right -->
    <ul class="nav navbar-nav navbar-right">
        <!-- <li class="dropdown hidden-sm" is-open="lang.isopen" dropdown>
            <a href class="dropdown-toggle" dropdown-toggle>
              {{selectLang}} <b class="caret"></b>
            </a>
            <ul class="dropdown-menu animated fadeInRight w">
                <li ng-repeat="(langKey, label) in langs">
                    <a ng-click="setLang(langKey, $event)" href>{{label}}</a>
                </li>
            </ul>
        </li>
        <li class="hidden-xs">
            <a ui-fullscreen></a>
        </li> -->
        <!-- <li class="dropdown" dropdown>
            <a href class="dropdown-toggle" dropdown-toggle>
                <i class="icon-bell fa-fw"></i>
                <span class="visible-xs-inline">Notifications</span>
                <span class="badge badge-sm up bg-danger pull-right-xs">2</span>
            </a>
            <div class="dropdown-menu w-xl animated fadeInUp">
                <div class="panel bg-white">
                    <div class="panel-heading b-light bg-light">
                        <strong>You have <span>2</span> notifications</strong>
                    </div>
                    <div class="list-group">
                        <a href class="media list-group-item">
                            <span class="pull-left thumb-sm">
                      <img src="img/user.png" alt="..." class="img-circle">
                    </span>
                            <span class="media-body block m-b-none">
                      Use awesome animate.css<br>
                      <small class="text-muted">10 minutes ago</small>
                    </span>
                        </a>
                        <a href class="media list-group-item">
                            <span class="media-body block m-b-none">
                      1.0 initial released<br>
                      <small class="text-muted">1 hour ago</small>
                    </span>
                        </a>
                    </div>
                    <div class="panel-footer text-sm">
                        <a href class="pull-right"><i class="fa fa-cog"></i></a>
                        <a href="#notes" data-toggle="class:show animated fadeInRight">See all the notifications</a>
                    </div>
                </div>
            </div>
        </li> -->
        <li class="messageList" ng-controller="messageButtonCtrl">
            <div class="messageBtn" ng-click="showMessageList()">消息</div>
            <div ng-show="redPoint" class="redPoint"></div>
        </li>
        <li class="dropdown" dropdown>
            <a href class="dropdown-toggle clear" dropdown-toggle>
                <span class="thumb-sm avatar pull-right m-t-n-sm m-b-n-sm m-l-sm">
                <img src="img/user.png" alt="...">
                <i class="on md b-white bottom"></i>
              </span>
                <span class="hidden-sm hidden-md">{{userPhone.phone}}</span> <b class="caret"></b>
            </a>
            <!-- dropdown -->
            <ul class="dropdown-menu animated fadeInRight w">
                <!-- <li class="wrapper b-b m-b-sm bg-light m-t-n-xs">
                    <div>
                        <p>300mb of 500mb used</p>
                    </div>
                    <progressbar value="60" class="progress-xs m-b-none bg-white"></progressbar>
                </li>
                <li>
                    <a href>
                        <span class="badge bg-danger pull-right">30%</span>
                        <span>Settings</span>
                    </a>
                </li>
                <li>
                    <a ui-sref="app.page.profile">Profile</a>
                </li>
                <li>
                    <a ui-sref="app.docs">
                        <span class="label bg-info pull-right">new</span> Help
                    </a>
                </li>
                <li class="divider"></li> -->
                <li>
                    <a ui-sref="app.houseOwner.changePsw">修改密码</a>
                </li>
                <li>
                    <a ui-sref="access.signout">退出登录</a>
                </li>
            </ul>
            <!-- / dropdown -->
        </li>
    </ul>
    <!-- / navbar right -->
</div>
<!-- / navbar collapse -->
<script type="text/javascript">
    $("#screenChanged").on("click",function(){
        $(".dataTables_scrollHeadInner").css('width', '100%');
    });

    app.controller('messageButtonCtrl', function($scope,$http,rest,$compile,$location,ngDialog,user,$state,$window,uiLoad,$rootScope,$ocLazyLoad) {
        $scope.params = {
            openId: user.get('openId')
        };
        rest.post({
            methodId: '3015',
            data: $scope.params,
            success: function(res) {
                if (res.code == 0) {
                  $scope.data = res.res.data;
                  $scope.$apply( function(){
                    
                    $scope.data = res.res.data;
                    // console.log(res.res.data);
                    if (res.res.data == 0) {
                        $scope.redPoint = 0
                    }else{
                        $scope.redPoint = 1
                        $scope.newMessageNum = res.res.data;
                    }

                  })
                }
              },
              error: function() {
                console.log( "失败！");
              }
        });
        $scope.showMessageList = function(){
            ngDialog.openConfirm({
              template: 'views/houseOwner/messageList.html',
              resolve: {
                load: function() {
                  return uiLoad.load(['js/controllers/houseOwner/messageList.js'])
                }
              },
              data:{},
              scope: $scope,
              width: 1000,
              // height: 700
            }).then(function(data) {
                // $scope.dataTable.fnClearTable();
                window.location.reload()
            }, function(reason) {
                // $scope.dataTable.fnClearTable();
                window.location.reload()
            });
        }
    });
</script>